package kama;

import java.util.HashMap;
import java.util.Scanner;

public class Test0104 {
}

class Main0104_1{
    static int record=1;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int length1 = scanner.nextInt();
        int length2 = scanner.nextInt();

        int[][] graph = new int[length1][length2];
        for (int i = 0; i < length1; i++)
            for (int j = 0; j < length2; j++)
                graph[i][j] = scanner.nextInt();

        HashMap<Integer, Integer> map = new HashMap<>();
        map.put(0, 0);

        for (int i = 0; i < length1; i++) {
            for (int j = 0; j < length2; j++) {
                if (graph[i][j] == 1) {
                    map.put(++record, calSize(i,j,graph));
                }
            }
        }

        int max = 0;
        for (int i = 0; i < length1; i++) {
            for (int j = 0; j < length2; j++) {
                if (graph[i][j] == 0) {
                    int now=1;
                    if (i>0) now+= map.get(graph[i- 1][j]);
                    if (j>0) now+= map.get(graph[i][j- 1]);
                    if (i<length1-1) now+=map.get(graph[i+1][j]);
                    if (j<length2-1) now+=map.get(graph[i][j+1]);
                    max=Math.max(max,now);
                }
            }
        }

        System.out.println(max==0?length2*length1:max);
    }

    public static int calSize(int i, int j, int[][] graph) {
        if (i<0 || j<0 || i>=graph.length || j>=graph[i].length||graph[i][j]!=1) return 0;

        graph[i][j] = record;

        int size = 1;
        size+= calSize(i-1, j, graph);
        size+= calSize(i, j-1, graph);
        size+= calSize(i+1, j, graph);
        size+= calSize(i, j+1, graph);

        return size;
    }

}
